<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100vw;
            height: 100vh;
            background-color: #000;
        }
        #cloud{
            position: relative;
            width: 320px;
            height: 80px;
            background-color: #b0aaaa;
            border-radius: 50px;
        }
        #cloud::after{
            content: "";
            position: absolute;
            bottom: -150px;
            width: 100%;
            height: 10px;
            background-color: #b0aaaa;
            border-radius: 50%;
        }
        #clouds{
            position: absolute;
            top: -50px;
            left: 50px;
            width: 90px;
            height: 90px;
            border-radius: 50%;
            background-color: #b0aaaa;
        }
        #clouds::after{
            content:"";
            position: absolute;
            left: 80px;
            top: -30px;
            width: 130px;
            height: 130px;
            background-color: #b0aaaa;
            border-radius: 50%;
        }
        #rains{
            display: flex;
            position:absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%);
        }
        #rains div{
            width: 10px;
            height: 10px;
            margin: 0 5px;
            border-radius: 50%;
            background-color: #b0aaaa;
            animation: animate linear 2s infinite;
            /* calc()函数动态计算*/
            animation-duration: calc(var(--i)*1s);
        }
        @keyframes animate {
            0%{
                transform: translateY(0) scale(0.2);
            }
            100%{
                transform: translateY(170px) scale(1);
            }
        }
    </style>
</head>
<body>
    <div id="root">
        <div id="cloud">
            <div id="clouds"></div>
            <div id="rains" ref="rains">
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el:'#root',
            mounted() {
                //生成雨滴
                for(let i=0;i<10;i++){
                    let rain = document.createElement('div');
                    //给每个雨滴添加一个随机的css局部变量
                    rain.style = `--i:${(Math.random()+1)/2}`;
                    this.$refs.rains.appendChild(rain);
                }
            },
        })
    </script>
</body>
</html>